/**
 * 通用接口
 */
import type { UploadImageResult } from './types';
import { post, upload } from '@/utils/request';

enum URL {
  upload = '/common/upload',
  uploads = '/common/uploads',
}

// 单文件上传
export const uploadFile = (data: { file: string }) => post<UploadImageResult>({ url: URL.upload, data });

// 多文件上传
export const uploadFiles = (data: { files: Array<string> }) => post<UploadImageResult>({ url: URL.uploads, data });

export const uploadImage = (imagePath: string) =>
  upload<UploadImageResult>({ url: URL.upload, filePath: imagePath, name: 'file' });
